package fileIO;

import java.util.ArrayList;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import storage.FieldInfo;



public class CellIO {
	public static String ConverttoStr(Cell cell){
		String cellStr = "";
		if (cell.getCellType()==Cell.CELL_TYPE_STRING)
			cellStr= cell.getStringCellValue().toUpperCase();
		else if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC)
			cellStr = Integer.toString((int)cell.getNumericCellValue());
		
		return cellStr;
	}
	public static String ConverttoStrNor(Cell cell){
		String cellStr = "";
		if (cell.getCellType()==Cell.CELL_TYPE_STRING)
			cellStr= cell.getStringCellValue();
		else if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC)
			cellStr = Double.toString(cell.getNumericCellValue());
		
		return cellStr;
	}	
	public static String keyGenerator(Row row){
		String keyStr = "";
		int i = 0;
		ArrayList<Integer> eCol = FieldInfo.getExceptionField();
		while(i<eCol.size()){
			if (keyStr == "")
				keyStr = ConverttoStr(row.getCell(eCol.get(i)));
			else
				keyStr = keyStr + "," + ConverttoStr(row.getCell(eCol.get(i)));
			i++;
		}
		keyStr = keyStr.toUpperCase();
		return keyStr;
		
	}
	public static boolean rowComparison(Row firstRow, Row secondRow){
		
		return false;
	}
}
